#include<iostream>
#include"MyArray.hpp"

void PrintArray(MyArray <int>& arr)
{
	for(int i = 0; i < arr.GetSize(); i++)
	{
		std::cout << arr[i] << std::endl;
	}
}
void test()
{
	MyArray <int>m_arr(5);
	for (int i = 0; i < 5; i++)
	{
		m_arr.PushBack(i);
	}
	std::cout << "m_arr的打印输出为：" << std::endl;
	PrintArray(m_arr);
	std::cout << "m_arr的容量为：" << m_arr.GetCapacity() << std::endl;
	std::cout << "m_arr的大小为：" << m_arr.GetSize() << std::endl;

	MyArray <int>m_arr1(m_arr);
	std::cout << "尾删前m_arr1的打印输出为：" << std::endl;
	PrintArray(m_arr1);
	m_arr1.PopBack();
	std::cout << "尾删后m_arr1的打印输出为：" << std::endl;
	PrintArray(m_arr1);
	std::cout << "m_arr1的容量为：" << m_arr1.GetCapacity() << std::endl;
	std::cout << "m_arr1的大小为：" << m_arr1.GetSize() << std::endl;

	/*MyArray <int>m_arr1(m_arr);
	MyArray <int>m_arr2(16);
	m_arr2 = m_arr;*/
}
//自定义数据类型
class Person
{
public:
	std::string m_name;
	int m_age;
	Person()
	{

	}
	Person(std::string name, int age)
	{
		this->m_name = name;
		this->m_age = age;
	}
};
void PersonPrint(MyArray<Person>& arr)
{
	for (int i = 0; i < arr.GetSize(); i++)
	{
		std::cout << "名字：" << arr[i].m_name << "  " << "年纪：" << arr[i].m_age << std::endl;
	}
}

void test1()
{
	MyArray<Person> arr(3);
	Person p1("Jack", 16);
	Person p2("John", 20);
	Person p3("Tarry", 25);
	arr.PushBack(p1);
	arr.PushBack(p2);
	arr.PushBack(p3);

	std::cout << "arr打印结果如下：" << std::endl;
	PersonPrint(arr);
	std::cout << "arr的容量为：" << arr.GetCapacity() << std::endl;
	std::cout << "arr的大小为：" << arr.GetSize() << std::endl;

}

int main()
{
	test();
	test1();
	std::cin.get();
	return 0;
}